package com.tt.job.common.concurrent.atomic;

import sun.misc.Unsafe;

import java.io.Serializable;

public final class AtomicUnsignedShort extends Number implements Serializable {
    private static final Unsafe unsafe = Unsafe.getUnsafe();
    private static final long valueOffset;

    static {
        try {
            valueOffset = unsafe.objectFieldOffset
                    (AtomicUnsignedShort.class.getDeclaredField("value"));
        } catch (Exception ex) {
            throw new Error(ex);
        }
    }

    private volatile int value;

    public AtomicUnsignedShort(int initialValue) {
        value = initialValue;
    }

    public AtomicUnsignedShort() {

    }

    public final int get() {
        return value;
    }

    public final void lazySet(int newValue) {
        unsafe.putOrderedInt(this, valueOffset, newValue);
    }

    public final void set(int newValue) {
        value = newValue;
    }

    @Override
    public int intValue() {
        return 0;
    }

    @Override
    public long longValue() {
        return 0;
    }

    @Override
    public float floatValue() {
        return 0;
    }

    @Override
    public double doubleValue() {
        return 0;
    }
}
